How to refactor your creepy Halloween bot... into a Christmas elf bot!
Tags: azure, bot, node, ai
Published: 2020-12-05 04:30:04

> There's room for everyone on the nice list.

In October, I made a [Halloween bot](https://github.com/lynnaloo/scream-caller-bot) based on the movie Scream. And it ended up [getting a little creepy](https://res.cloudinary.com/practicaldev/image/fetch/s--3pcDmqh8--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/vtnia7tl60bc4eoy8ijr.png).

For the holidays, I decided that I wanted turn my creepy Halloween bot into a jolly Christmas bot, based on the movie [Elf](https://www.imdb.com/title/tt0319343/). 

![Santas coming](https://media.giphy.com/media/3ofT5EtPNBpIjC8jTy/giphy.gif)

![Elf greeting](https://dev-to-uploads.s3.amazonaws.com/i/6nxuojvo5o8uytxia5p3.png)

&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
**Now, you should make a jolly (and a little bit creepy) Christmas bot too!**

---

### Create a knowledge base for your Buddy-bot

![Meet Elf](https://media.giphy.com/media/26mfytnSNmNAhZmnK/giphy.gif)

To give your Buddy-bot the ability to answer questions, you'll need to create a QnA Maker service and a knowledge base. You can fill the knowledge base with personalized answers and fill in the conversation gaps with some pre-made "chit-chat." 

* Sign into [QnA Maker Portal](https://qnamaker.ai/) using your Azure credentials.
* Create a new QnA knowledge base or import an [existing elf knowledge base](https://github.com/lynnaloo/scream-caller-bot/blob/main/elf-knowledge-base.tsv).
* When you're done tweaking the question and answers for your bot and training the model, select "PUBLISH."
* Once your QnA Maker app is published, select "SETTINGS" and note the values from the "Deployment details" section. You’ll need these later.

``` bash
POST /knowledgebases/<knowledge-base-id>/generateAnswer
Host: https://<yourqna>.azurewebsites.net/qnamaker
Authorization: EndpointKey <resource-key>
```
---

### Scream-bot becomes Buddy-bot

For detailed instructions on creating an Azure Bot Service, you can find the steps [here](https://dev.to/lynnaloo/how-i-accidentally-created-a-creepy-halloween-bot-and-you-can-too-1ed7). Instead of downloading and making changes to the sample bot code, can also clone and deploy [my sample bot code](https://github.com/lynnaloo/scream-caller-bot).

**Note:** Use the keys from the QNA Maker knowledge base that you just made to set the environment variables in the application settings of your bot's App Service instance.

``` bash
QnAKnowledgebaseId=<knowledge-base-id>
QnAAuthKey=<resource-key>
QnAEndpointHostName="https://<yourqna>.azurewebsites.net/qnamaker"
WelcomeText='Buddy the Elf!'
UnknownText='So, good news—I saw a dog today.'
```

You might also want to upload your own custom Buddy icon in the setting of your bot to make it more... cheerful.
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;

![Icon](https://dev-to-uploads.s3.amazonaws.com/i/f9hwpf0snun2lovv0405.png)

---

Now, test your bot using the "Test in Web Chat" option under "Bot management."

![Santa!](https://media.giphy.com/media/l1AvyLF0Sdg6wSZZS/giphy.gif)
<br>

![Settings](https://dev-to-uploads.s3.amazonaws.com/i/eukvczydkzn15hgrl4tq.png)
<br>

**Congrats!** You now have a more cheerful and slightly less creepy holiday bot!
<br>

![Color](https://dev-to-uploads.s3.amazonaws.com/i/5emh2dooyt7wlf1e8d5x.png)

![Bye](https://media.giphy.com/media/xUySTVNHpdACknfKuc/giphy.gif)
<br>

**Resources:**
* [Scream-bot](https://github.com/lynnaloo/scream-caller-bot) 
* [Scream-bot blog](https://dev.to/lynnaloo/how-i-accidentally-created-a-creepy-halloween-bot-and-you-can-too-1ed7)
* [Bot Basics](https://docs.microsoft.com/azure/bot-service/bot-builder-basics?view=azure-bot-service-4.0)
* [Azure Bot Service Documentation](https://docs.microsoft.com/azure/bot-service/?view=azure-bot-service-4.0)