Skip to content

How To Use

Alex Vidal edited this page Jul 8, 2023 · 51 revisions

  1. Requisites
  2. Github steps
  3. AWS steps
  4. Post deploy
  5. Operation
  6. Delete resources


Requisites

The "Jepetobot" application does not require any type of installation for its implementation.

As the entire infrastructure is automated in the cloud, it is not necessary to install anything locally. You only need to have the following:




  • The Github account is necessary to fork the code and to be able to execute the deployment automations

  • To create an account on Github, go to the official website and follow the steps described there.




  • Obviously, you need a Telegram account to deploy a bot on Telegram.

  • To create a Telegram account, you must download a Telegram client and follow the steps described there.

  • It is necessary to obtain a token from the Telegram Bot API.

  • Instructions for it are HERE.






  • All the infrastructure of the application is deployed in AWS, therefore, an account is needed in said public cloud provider to be able to create the necessary resources.

  • You can see how to create an AWS account HERE

  • It is necessary to obtain a Access Key and a Secret Access Key from the AWS Management Console.

  • Instructions for it are HERE






  • The main functionality of Jepetobot is based on the OpenAi api, therefore an account is needed there.

  • To create an OpenAi account, you can click HERE

  • It is necessary to obtain a token from the OpenAI API.

  • Instructions for it are HERE.


❗ Although not recommended, this guide assumes that the AWS keys to be used are root user to avoid further complexity. If you are an advanced AWS user, you can use a user with more appropriate custom permissions for this task.
⚡ All use of cloud and OpenAi api generate costs, use it at your own risk!



Github steps

First of all, once you are logged into Github, you must go to the jepetobot repository and click on the fork button as indicated in the following image:





At that point, you will have a copy of the project in your Github account that you can customize.

Once the Jepetobot project is located in your Github account, you must enter in settings:





Next, you must go to "secrets and variables" and click on "Actions":





Once there, you must click on "New repository secret" and add the following secrets:

  • AWS_ACCESS_KEY_ID:
    It's a set of credentials that allow you to programmatically access AWS services and resources. Instructions for get it are HERE.

  • AWS_KEY (optional, see example):
    If you want to use a private key (.pem file) to access the ec2 instance created, you must specify the name of said private key here.
    (eg. NONE)

  • AWS_ACCOUNT:
    It's a unique identifier assigned to an Amazon Web Services (AWS) account. It is a 12-digit number that is used to identify and authenticate the AWS account when accessing AWS services and resources.

  • AWS_REGION:
    AWS Region where the resources will be deployed. This section is important because not all regions have the same services or prices.
    (eg. eu-west-1)

  • AWS_SECRET_KEY:
    It's a long, secret string of characters that is used to authenticate and authorize access to AWS services and resources. Together with an access key ID, the secret key is used to sign requests made to AWS services, ensuring that only authorized users and applications can access the resources.

  • AWS_SG (optional, see example):
    If you want to use an existing AWS Security group (A a type of virtual firewall that allows you to control network traffic entering and leaving your cloud resources), you must specify it here. By default an automatic Security group is created if you put "NONE" here.
    (eg. NONE)

  • AWS_SG_PORTS (optional, see example):
    If you specify the value "NONE" in AWS_SG, a Security Group will be created by default. So, the open ports for that Security Group will be set here.
    (eg. [80,443], brackets included)

  • AWS_TAG_NAME:
    It's a label or metadata key-value pair that can be applied to AWS resources.
    (eg. jepeto)

  • AWS_VPC_ID:
    By default when creating the AWS account, AWS creates a default vpc per region, whose id can be used to insert here. Any valid vpc id can be used. Automatic VPC creation is not done yet.

  • SECRET_ADMINS:
    Here you must enter the id of the telegram users who will have an administrator role in Jepetobot.
    (eg. [123456789], brackets included)

  • SECRET_OPENAI:
    The OpenAI token mentioned in previous sections must be entered in this field.

  • SECRET_TELEGRAM:
    The Telegram bot token mentioned in previous sections must be entered in this field.

  • SECRET_USERS:
    Here you must enter the id of the telegram users who will have a normal role in Jepetobot.
    (eg. [123456789, 987654321], brackets included)


Finally it should be something like this:





The next step within Github is to execute the "action" that will deploy all the infrastructure in the AWS cloud. Therefore, within the Github repository, you must click on "Actions":





And then in "Deploy Resources":





Finally, by clicking on "Run Workflow", the Jepetobot resources will be automatically deployed in the cloud:





Thus, when clicking again on "Actions", it will be seen how a new execution has been generated:





Running Success



⚡ The deployment usually takes about 10 minutes to complete, if the execution of the "action" has been correct (green tick), everything should be fine.



OPTIONAL STEP: When the execution has completed successfully, we can verify that the resources have been deployed correctly. In this way, you have to enter AWS and access the Cloudformation service:





Click on "Stacks":





And you should see something similar to the following:





With the infraestructure resources and the jepetobot code correctly set, Jepetobot is already deployed in the cloud and you can continue to the next AWS section.




Post deploy

To start Jepetobot in Telegram, you must find it in the Telegram search button by the name you assigned it when creating the Telegram token.

Once located, when trying to talk to him, Jepetobot's response will be that it does not have permissions to respond to the user, and then it will display a number. This happens in case the correct Telegram ids have not been entered in the Github Actions secrets.


⚡ If jepetobot doesn't work, check the FAQ. An application redeployment may be required.

That number is the telegram user id of the person Jepetobot is replying to and will need to be entered in "SECRET_USERS". In this way, once the Telegram ids that need to be entered have been detected, the steps described above must be repeated. This time the secret of "SECRET_ADMINS" and "SECRET_USERS" should have the correct Telegram ids.


⚡ The reason for having this very restrictive policy by default is to keep OpenAI API costs under control.

Additionally, to confirm the correct operation of Jepetobot, you can go to the AWS Cloudwatch service and search the "log group" section:





There should be a group called "Jepetobot-log_group", and within said group, three log streams should be located as in the image:





Each log stream saves a series of records that monitor the application. This example can be seen in the following image:






⚡ All use of cloud and OpenAi api generate costs, use it at your own risk!



Operation

Below is a brief animated sample of the possibilities of Jepetobot:


Adapted to the latest chatgpt model 'Identity' change from bot options 'Temperature' change from bot options

In case of having problems and not finding anything in the Cloudwatch logs, manually redeploy Jepetobot using the "update_application" Github action workflow as it was done in the Github steps of this guide with "deploy_resources" workflow. Then, check the FAQ for more information.




Delete Jepetobot

If, once Jepetobot has been deployed on AWS, you want to remove it from your AWS account for any reason, it's as simple as running the Github actions workflow called "delete_resources". This process is described in the following image:





Clone this wiki locally