Rochdy / shop-bot

A small shopping cart bot using Symfony PHP framework, and Messenger API

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

The ShopBot

Used Packages

  • FOSUserBundle \ SonataAdmin: To create admin system
  • FB Messenger Bot PHP API: To communicate with Messenger API
  • DIExtraBundle: To configure dependency injection using annotations
  • Doctrine ORM: To manage objects
  • Twig: As a template engine

Entities There are 4 entities in this app [Cart/Customer/User/Product].

  • Customer and User Entity are not related to each others.
  • I kept the Product entity as simple as possible, only the name & price.
  • Customer entity does not have any information for the customer but the sender id, i wanted to store the user name, but what if the user changed his name? so i'm storing only the sender id.

Chat scenario The bot has only 6 types of messages to reply with:

  • Welcome message: after the user first interaction
  • Products message: if the user sent a message conatein 'products' word, or when the user clicked a postback button to see all products
  • Cart message: if the user sent a message contain 'cart' word, or when the user clicked a postback button to see his cart
  • Add product message: if the user added a product to his cart & IT MUST BE A POSTBACK
  • Remove product message: if the user removed a product to his cart & IT MUST BE A POSTBACK
  • Default message: sent if the bot did not what the user wants

Some obstacles faced me

  • Facebook lists accepts only 2-4 items, so i used the generic template

Somethings i wanted to do and why i didn not

  • Use Symfony Forms: There is no place to use it in this app, admin forms are generated by sonata bundle.
  • Use Doctrine Eventlistener

About

A small shopping cart bot using Symfony PHP framework, and Messenger API


Languages

Language:PHP 92.3%Language:HTML 7.7%