Skip to content

WingsMaker/imagebot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 

Repository files navigation

Introduction

How to create serverless telegram chatbot to generate image using google app script and OpenAI Dall.E API from OpenAI.

image

Requirements

Getting Started - Google App Script Project

[1] Goto https://script.google.com/home , click "New Project"

[2] Write the scripts, copy paste from below template url :

https://raw.githubusercontent.com/WingsMaker/chatgptbot/main/imagebot_gas.txt

[3] Rename the project

Click on the "Untitled project" to rename the project as something else. Example, "My ChatGPT bot".

image

[4] Deploy as google web app

In the Google App Script project, go to "Publish" in the top navigation bar. Under "Deploy as web app", select "Deploy". This will open a pop-up window. Your web app URL will be listed in the "Current web app URL" field.

Click on the "Deploy - New Deployment"

image

Click "Select type - Web App"

image

Fill in the form and click "Deploy". ( for more see https://www.youtube.com/watch?v=-AlstV1PAaA )

image

Copy the web app url to the clipboard for later use.

[5] Update the values of weburi in the script.

Remove the substrings "https://script.google.com/macros/s/" and "/exec" of url. Copy the result to clipboard. Change the value of statement, paste the weburi address into here.

var weburi = "paste_here";

[6] Update the values of token in the script.

Find your Telegram chatbot token by logging into the BotFather in Telegram, selecting your bot, and clicking the "API Token" button. ( see https://www.youtube.com/watch?v=aNmRNjME6mE ) Change the value of statement, paste the bot token into here.

var token = "replace_here";

[7] Update the values of apiKey in the script.

The api secret key for Chat GPT is located in the My Apps page of your Chat GPT dashboard. ( for more see https://www.youtube.com/watch?v=DFmmiYlbgX0 ) Change the value of statement, paste the api secret key into here.

var apiKey = "replace_here";

[8] Save the script and REDO the deployment process in step 4

since the code has been changed, need to update the value of webappUrl in [7].

[9] Run the "start_bot" function for only once to make sure actual telegram bot able to callback this google web app.

image

Your telegram bot is ready !

Reference https://platform.openai.com/docs/guides/images/

About

How to create serverless telegram chatbot using google app script and CHATGPT api

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published