✨ (sdk) createConversation implementation
Implement Decidim API usages, to get user by internal chatbot id, or register it (upsert logics).
Usage:
import DecidimSDK from "./decidim_sdk";
const sdk = new DecidimSDK({
apiBaseUrl: "https://nca.voca.city",
clientId: "i0Rp-my-client-id",
clientSecret: "qaG0cu-my-client-secret"
})
sdk.createConversation(
"chatbot-economic-assembly:whatsapp-my-number:anything",
"",
"",
{someExtraData: "hello,world"}
)
Results:
debug: create conversation chatbot-economic-assembly:whatsapp-my-number:anything {"sdk":"DecidimSDK"}
debug: create conversation chatbot-economic-assembly:whatsapp-my-number:anything..... [chatbotId=chatbot-economic-assembly, userId=whatsapp-my-number] {"sdk":"DecidimSDK"}
debug: get machine-to-machine token for i0Rp***** {"sdk":"DecidimSDK"}
debug: search chatbotUserid=whatsapp-my-number {"sdk":"DecidimSDK"}
debug: search chatbotUserid=whatsapp-my-number...... found 1 {"sdk":"DecidimSDK"}
debug: create conversation: done. User swmtczmzeymjq5nzc0na ready to chat {"sdk":"DecidimSDK"}
=> This user can be seen in the Decidim Profile page of swmtczmzeymjq5nzc0na
Edited by Hadrien Froger