A simple Discord bot that can be used as an example when connecting Dialogflow.
- Fork this repo using:
git clone https://github.com/biagios/discord-bot-dialogflow-example
- Once forked browse to the directory where it was installed:
cd /yourdirectoryforthefilehere/
- Install the required dependencies using npm:
If you are only using the repo as an example and just want the basic main dependencies needed these are:
dialogflow
&@google-cloud/storage
(and of coursediscord.js
)
npm install
-
Once installed please compile your
config.js
file. -
Follow the instructions found here in order to create a Google Cloud service account.
Dialogflow should normally automatically create one for you! If you are certain it has then you should be able to simply execute the following command (populating the fields[NAME]
and[PROJECT_ID]
.)
gcloud iam service-accounts keys create keyfile.json --iam-account [NAME]@[PROJECT_ID].iam.gserviceaccount.com
- Once you have a keyfile.json you must define it. (It should automatically find it and log you in but it's best to define it)
Run the following in your terminal, populating
[PATH]
with the path to thekeyfile.json
, I recommend leaving this in wherever you put yourconfig.js
:
export GOOGLE_APPLICATION_CREDENTIALS="[PATH]"
- Once you have completed the above steps, head to
/modules/dialog.js
(or your equivalent module) and head to line10
to13
.
On the line containing:const projectId = '[PROJECT_ID]'
replace[PROJECT_ID]
with the project ID you used in step 5.
On the line containing:const keyFilename = './keyfile.json'
make sure the path defined is where yourkeyfile.json
is found.
If you have followed the installation process above the las thing you need to do is start the bot. This is easily done by executing the following:
node bot.js
Contributions, issues and feature requests are welcome!
Feel free to check issues page. You can also take a look at the contributing guide.