Skip to content

Instantly share code, notes, and snippets.

View ptrckbp's full-sized avatar

Patrick Hamelin ptrckbp

  • Botpress
View GitHub Profile
@ptrckbp
ptrckbp / dalle-chat.md
Created February 21, 2023 16:21
how to add image generation to your chatbot

You should have four flow variables :

peopleAmount (string type) peopleAction (string type) imageStyle (string type) outputUrls (array type)

After creating your prompt (which saves the answers to the first three variables), add this code to the next node to get the urls of the images. They will be stored to outputUrls.

* {
background-color: red!important;
}
@ptrckbp
ptrckbp / dashbot-analytics-incoming.js
Last active January 26, 2023 17:50
Adding Dashbot to Botpress
const DEBUG_DEV = false // set to true to test without setting EXPOSED_EXTERNAL_ANALYTICS=true in your environment
const DASHBOT_KEY = '165agsuvsjRfYOMXlenCCx3RzWc9wTAbMtbVGKn9' // change this to your Dashbot API key.
const DASHBOT_INBOUND_LINK = `https://tracker.dashbot.io/track?platform=universal&v=11.1.0-rest&type=incoming&apiKey=${DASHBOT_KEY}`
const DASHBOT_UNHANDLED_INTENT = 'NotHandled'
const axios = require('axios')
// Modify this if you are tracking authenticated user.
const getUserMeta = () => {
return {
@ptrckbp
ptrckbp / get-rover-images.js
Last active October 13, 2021 14:28
Example Botpress Custom Action - Mars Rover Photography Chatbot Follow Along Tutorial
function action(bp: typeof sdk, event: sdk.IO.IncomingEvent, args: any, { user, temp, session } = event.state) {
/** Your code starts below */
// replace DEMO_KEY with your api key if you have one, or get a new one if you hit the limit of yours.
const API_KEY = 'DEMO_KEY'
// if there is an error with the api, this is most likely due to api limit hit, tell the user how to solve the problem
const tellUserToGetApiKey = async () => {
// general structure of a message
const baseMessage = {
"function action(bp: typeof sdk, event: sdk.IO.IncomingEvent, args: any, { user, temp, session } = event.state) {
/** Your code starts below */
// replace DEMO_KEY with your api key if you have one, or get a new one if you hit the limit of yours.
const API_KEY = 'DEMO_KEY'
// if there is an error with the api, this is most likely due to api limit hit, tell the user how to solve the problem
const tellUserToGetApiKey = async () => {
// general structure of a message
const baseMessage = {
@ptrckbp
ptrckbp / questions_and_answers.json
Created September 29, 2021 13:23
File to import question into Mars Rover Photography Bot
{
"qnas": [
{
"id": "5477wmg2qo_what_is_the_latency_between_mars_and_earth",
"data": {
"action": "text",
"contexts": [
"global"
],
"enabled": true,